package com.learn.ch02ttlqueue.confim_advance.controller;

import com.learn.ch02ttlqueue.confim_advance.config.RabbitConfig;
import jakarta.annotation.Resource;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/08/24
 * @description ch08 发布确认高级
 * 高级在于要面对exchange or queue 当季的情况
 */
@RestController
public class ConfirmController {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/confirm/send/{message}")
    public void senMsg(@PathVariable("message") String message) {
        rabbitTemplate.convertAndSend(RabbitConfig.CONFIRM_EXCHANGE,
                RabbitConfig.CONFIRM_ROUTING_KEY + "!",
                message,
                // UUID做id，封装了回调消息
                new CorrelationData());
    }
}
